package com.kuang.pojo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

//等价于 <bean id="user" class="com.kuang.pojo.User"/>
//有了config后不用xml配置文件也可以直接@Component来说明这个类被Spring接管了，注册到了容器中
@Component
@Scope("singleton")
public class User {
    /*相当于<bean id="user" class="com.kuang.pojo.User">
        <property name="name" value="wangchao"/>
        </bean>*/
    @Value("wangchao")
    public String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                '}';
    }
}